import Vue from 'vue';

import baseUrl from '@/common/baseUrl.js';


// 网络图片
function ftpUrl(url){
	
	if (url.startsWith('http://') || url.startsWith('https://')) return url;
	
	return baseUrl.imageUrl + url;
	
	
}
Vue.prototype.$ftpUrl= ftpUrl;

//url地址
function Url(url){
	if (url.startsWith('http://') || url.startsWith('https://')) return url;
	return baseUrl.url + url;
}
Vue.prototype.$Url= Url;

//查看
function lookImage(url){
   uni.previewImage({
   	urls:url,
	current:1
   })
}
Vue.prototype.$LookImage= lookImage;

// go
function go(url){
	uni.navigateTo({
		url:url
	})
}
Vue.prototype.$Go= go;

// getParams
function getParams(url){
	let params = {}
	url = decodeURIComponent(url);
	let pindex = url.indexOf('?');
	if (pindex !== -1) {
		let str = url.substr(pindex + 1);
		let strs = str.split("&");
		for (let i in strs) {
			var item = strs[i].split('=');
			params[item[0]] = item[1];
		}
	}
	return params
}
Vue.prototype.$getParams= getParams;

